<?php

require_once 'classes/data/BaseDAO.class.php';

/**
 * * <description>
 *
 * @author      John J. GARCIA  <j.garcia_fernandez@fotovista.com>
 * @date        <date>
 */
class UserDAO extends BaseDAO {
    
    public function create()
    {   
        return true;
    }
    
    public function findAll()
    {
        return true;
    }
    
    public function findById($iUserId)
    {
        return true;
    }
    
    public function findByLogin($sLogin, $sPassw)
    {
        $sLogin = $this->getSQLValueString($sLogin, self::_MYSQL_TYPE_TEXTE);
        $sPassw = $this->getSQLValueString($sPassw, self::_MYSQL_TYPE_TEXTE);

        $sql = " 
            SELECT *
            FROM `users`
            WHERE `username` = $sLogin";

        $rs = mysql_query($sql, $this->_oDbConn);

        //Si erreur ...
        if ( ! $rs)
        {
            throw new Exception();
        }

        $totalRows = mysql_num_rows($rs);

        if ($totalRows > 0)
        {
            if ($row = mysql_fetch_assoc($rs))
            {
                // @FIXME Delete this !
                echo '<br />? ';
                var_dump($row);
                echo '<br /><=========================================================>';
            }
        }
        
        return false;
    }

}

?>
